<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">资源管理</a>
        <a href="#">教学教案</a>
        <a href="#">分类管理</a>
        <a href="#">编辑信息</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:window.location.reload();" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div style="height: 50px"></div>
<div style="width: 300px">
    <form class="layui-form" action="" name="type" onclick="return false" id="type">
        <input type="hidden" name="id" value="{$data.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">子类名称</label>
            <div class="layui-input-block">
                <input type="text"  value="{$data.title}" readonly placeholder="类别名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">原父类名称</label>
            <div class="layui-input-block">
                <input type="text" value="{$parentInfo.title}" readonly placeholder="类别名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新父类名称</label>
            <div class="layui-input-block">
                <select name="parent_id" >
                    {foreach $typeInfo as $values}
                        <?php
                            $nbsp = substr_count($values['path'],",");
                            $m = str_pad("",$nbsp*6*5,"&nbsp;");
                        ?>
                        <option value="{$values.id}">{$m}|--{$values.title}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="update">立即修改</button>
                <button class="layui-btn layui-btn-primary" onclick="window.history.back(-1); ">返回</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>
    $("#update").click(function(){
        $.ajax({
            url:"{:url('/plan_type/updateTypeParent')}",
            data:$("#type").serialize(),
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.location.reload();
                    })
                }else{
                    layer.msg(res.msg,{icon:5,time:2000})
                }
            }
        });
    });
</script>
</html>